package com.fifth.business.controller.api;

import com.fifth.business.service.BusinessPermissionService;
import com.fifth.business.service.BusinessService;
import com.fifth.common.pojo.dto.CommonResult;
import com.fifth.common.pojo.entity.BusinessInfo;
import com.fifth.common.pojo.entity.BusinessPermission;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @作者：刘壬杉
 * @创建时间 2022/8/31 11:38
 **/
@RestController
@RequestMapping("api/business")
public class ApiBusinessController {
    @Autowired
    private BusinessService businessService;

    @Autowired
    private BusinessPermissionService businessPermissionService;

    /**
     * 根据tel查询商户信息
     * @param telephone
     * @return
     */
    @GetMapping("findByPhone/{telephone}")
    public BusinessInfo findByPhone(@PathVariable String telephone){
        return businessService.findByPhone(telephone);
    }

    /**
     * 查询所有商家权限
     */
    @GetMapping("getPermission")
    public List<BusinessPermission> getPermission(){
        return businessPermissionService.getPermission();
    }

    /**
     * 查询所有商铺
     */
    @GetMapping("selectshop")
    public CommonResult selectshop(){
        return businessService.selectshop();
    }

    /**
     * 根据销量显示前四个
     */
    @GetMapping("/fourshop")
    public List<BusinessInfo> fourshop() {
        return businessService.fourshop();
    }

    /**
     * 根据销量查询全部排序
     */
    @GetMapping("/allshop")
    public List<BusinessInfo> allshop() {
        return businessService.allshop();
    }


    /**
     * 查询店铺数量总数
     */
    @GetMapping("numbershop")
    public Map numbershop(){
    return  businessService.numbershop();
    }

    /**
     * 查询商铺ip和店铺名
     */
    @PostMapping("ipshop")
    public List<BusinessInfo> ipshop(){
      return   businessService.ipshop();
    }

    /**
     * 根据店铺id修改店铺状态
     */
    @PostMapping("updatestate/{id}")
    public int getUpdatestate(@PathVariable String id) {
        return businessService.updatestate(id);

    }

    //统计店铺所卖所有商品类别个数
    @GetMapping("numberBusiness")
    public List<Map> numberBusiness(){
        return  businessService.numberBusiness();
    }

    /**
     * emp 调取
     * @return
     */
    @GetMapping("priceBusiness")
    public List<Map> priceBusiness(){

        return businessService.priceBusiness();
    }

    /**
     * home 用户调取 查询
     * @param bid
     * @return
     */
    @GetMapping("selectmarchant/{bid}")
    public BusinessInfo selectmarchant(@PathVariable String bid){
        return businessService.selectmarchant(bid);
    }
}
